Feature implementation from commits 7ce106a..f120b09#3
Open
codeOwlAI wants to merge 30 commits intofeature-base-branch-1from
Open
Feature implementation from commits 7ce106a..f120b09#3codeOwlAI wants to merge 30 commits intofeature-base-branch-1from
codeOwlAI wants to merge 30 commits intofeature-base-branch-1from
Conversation
…file Upgrade to GitHub-native Dependabot
Bumps [date-fns](https://github.com/date-fns/date-fns) from 2.21.1 to 2.21.2. - [Release notes](https://github.com/date-fns/date-fns/releases) - [Changelog](https://github.com/date-fns/date-fns/blob/master/CHANGELOG.md) - [Commits](date-fns/date-fns@v2.21.1...v2.21.2) Signed-off-by: dependabot[bot] <support@github.com>
…ate-fns-2.21.2 Bump date-fns from 2.21.1 to 2.21.2
Bumps [date-fns](https://github.com/date-fns/date-fns) from 2.21.2 to 2.21.3. - [Release notes](https://github.com/date-fns/date-fns/releases) - [Changelog](https://github.com/date-fns/date-fns/blob/master/CHANGELOG.md) - [Commits](https://github.com/date-fns/date-fns/commits) Signed-off-by: dependabot[bot] <support@github.com>
…ate-fns-2.21.3 Bump date-fns from 2.21.2 to 2.21.3
Bumps [@testing-library/user-event](https://github.com/testing-library/user-event) from 13.1.8 to 13.1.9. - [Release notes](https://github.com/testing-library/user-event/releases) - [Changelog](https://github.com/testing-library/user-event/blob/master/CHANGELOG.md) - [Commits](testing-library/user-event@v13.1.8...v13.1.9) Signed-off-by: dependabot[bot] <support@github.com>
…esting-library/user-event-13.1.9 Bump @testing-library/user-event from 13.1.8 to 13.1.9
Bumps [@testing-library/react](https://github.com/testing-library/react-testing-library) from 11.2.6 to 11.2.7. - [Release notes](https://github.com/testing-library/react-testing-library/releases) - [Changelog](https://github.com/testing-library/react-testing-library/blob/main/CHANGELOG.md) - [Commits](testing-library/react-testing-library@v11.2.6...v11.2.7) Signed-off-by: dependabot[bot] <support@github.com>
…esting-library/react-11.2.7 Bump @testing-library/react from 11.2.6 to 11.2.7
Bumps [@stripe/react-stripe-js](https://github.com/stripe/react-stripe-js) from 1.4.0 to 1.4.1. - [Release notes](https://github.com/stripe/react-stripe-js/releases) - [Changelog](https://github.com/stripe/react-stripe-js/blob/master/CHANGELOG.md) - [Commits](stripe/react-stripe-js@v1.4.0...v1.4.1) Signed-off-by: dependabot[bot] <support@github.com>
…tripe/react-stripe-js-1.4.1 Bump @stripe/react-stripe-js from 1.4.0 to 1.4.1
Bumps [@stripe/stripe-js](https://github.com/stripe/stripe-js) from 1.14.0 to 1.15.0. - [Release notes](https://github.com/stripe/stripe-js/releases) - [Commits](stripe/stripe-js@v1.14.0...v1.15.0) Signed-off-by: dependabot[bot] <support@github.com>
…tripe/stripe-js-1.15.0 Bump @stripe/stripe-js from 1.14.0 to 1.15.0
Bumps [date-fns](https://github.com/date-fns/date-fns) from 2.21.3 to 2.22.1. - [Release notes](https://github.com/date-fns/date-fns/releases) - [Changelog](https://github.com/date-fns/date-fns/blob/master/CHANGELOG.md) - [Commits](date-fns/date-fns@v2.21.3...v2.22.1) Signed-off-by: dependabot[bot] <support@github.com>
…ate-fns-2.22.1 Bump date-fns from 2.21.3 to 2.22.1
Bumps [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) from 5.12.0 to 5.13.0. - [Release notes](https://github.com/testing-library/jest-dom/releases) - [Changelog](https://github.com/testing-library/jest-dom/blob/main/CHANGELOG.md) - [Commits](testing-library/jest-dom@v5.12.0...v5.13.0) --- updated-dependencies: - dependency-name: "@testing-library/jest-dom" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
…esting-library/jest-dom-5.13.0 Bump @testing-library/jest-dom from 5.12.0 to 5.13.0
Bumps [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) from 5.13.0 to 5.14.1. - [Release notes](https://github.com/testing-library/jest-dom/releases) - [Changelog](https://github.com/testing-library/jest-dom/blob/main/CHANGELOG.md) - [Commits](testing-library/jest-dom@v5.13.0...v5.14.1) --- updated-dependencies: - dependency-name: "@testing-library/jest-dom" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
…esting-library/jest-dom-5.14.1 Bump @testing-library/jest-dom from 5.13.0 to 5.14.1
Bumps [@stripe/stripe-js](https://github.com/stripe/stripe-js) from 1.15.0 to 1.15.1. - [Release notes](https://github.com/stripe/stripe-js/releases) - [Commits](stripe/stripe-js@v1.15.0...v1.15.1) --- updated-dependencies: - dependency-name: "@stripe/stripe-js" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [@testing-library/react](https://github.com/testing-library/react-testing-library) from 11.2.7 to 12.0.0. - [Release notes](https://github.com/testing-library/react-testing-library/releases) - [Changelog](https://github.com/testing-library/react-testing-library/blob/main/CHANGELOG.md) - [Commits](testing-library/react-testing-library@v11.2.7...v12.0.0) --- updated-dependencies: - dependency-name: "@testing-library/react" dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [react-cropper](https://github.com/react-cropper/react-cropper) from 2.1.7 to 2.1.8. - [Release notes](https://github.com/react-cropper/react-cropper/releases) - [Commits](react-cropper/react-cropper@v2.1.7...v2.1.8) --- updated-dependencies: - dependency-name: react-cropper dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
…eact-cropper-2.1.8 Bump react-cropper from 2.1.7 to 2.1.8
…tripe/stripe-js-1.15.1 Bump @stripe/stripe-js from 1.15.0 to 1.15.1
…esting-library/react-12.0.0 Bump @testing-library/react from 11.2.7 to 12.0.0
Comment on lines
+13
to
+21
| useEffect( | ||
| () => | ||
| history.block( | ||
| (location, action) => | ||
| action !== "PUSH" || | ||
| getLocationId(location) !== getLocationId(history.location) | ||
| ), | ||
| [] // eslint-disable-line react-hooks/exhaustive-deps | ||
| ); |
There was a problem hiding this comment.
🐛 Correctness Issue
Memory Leak: Missing Cleanup Function.
The useEffect hook doesn't return the cleanup function from history.block(), which will cause memory leaks when components unmount.
Current Code (Diff):
- useEffect(
- () =>
- history.block(
- (location, action) =>
- action !== "PUSH" ||
- getLocationId(location) !== getLocationId(history.location)
- ),
- [] // eslint-disable-line react-hooks/exhaustive-deps
- );
+ useEffect(
+ () => {
+ const unblock = history.block(
+ (location, action) =>
+ action !== "PUSH" ||
+ getLocationId(location) !== getLocationId(history.location)
+ );
+ return unblock;
+ },
+ [] // eslint-disable-line react-hooks/exhaustive-deps
+ );📝 Committable suggestion
‼️ IMPORTANT
Trust, but verify! 🕵️ Please review this suggestion with the care of a code archaeologist - check that it perfectly replaces the highlighted code, preserves all lines, maintains proper indentation, and won't break anything in production. Your future self will thank you! 🚀
Suggested change
| useEffect( | |
| () => | |
| history.block( | |
| (location, action) => | |
| action !== "PUSH" || | |
| getLocationId(location) !== getLocationId(history.location) | |
| ), | |
| [] // eslint-disable-line react-hooks/exhaustive-deps | |
| ); | |
| useEffect( | |
| () => { | |
| const unblock = history.block( | |
| (location, action) => | |
| action !== "PUSH" || | |
| getLocationId(location) !== getLocationId(history.location) | |
| ); | |
| return unblock; | |
| }, | |
| [] // eslint-disable-line react-hooks/exhaustive-deps | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Add useLocationBlocker Hook to Prevent Duplicate History Entries
Overview
This PR introduces a new custom hook
useLocationBlockerthat prevents React Router from pushing the same page to history multiple times, improving navigation experience by avoiding duplicate history entries.Change Types
Affected Modules
shared/functions/useLocationBlocker.jslogged_in/components/Routing.jslogged_out/components/Routing.jsNotes for Reviewers